package com.example.content_android;

import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.content_android.ui.home.AnnouncementFragment;
import com.example.content_android.ui.home.ArticleListFragment;
import com.example.content_android.ui.me.MeFragment;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.scwang.smart.refresh.footer.ClassicsFooter;
import com.scwang.smart.refresh.header.ClassicsHeader;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnLoadMoreListener;
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
import com.youth.banner.Banner;
import com.zhihu.matisse.Matisse;
import com.zhihu.matisse.MimeType;
import com.zhihu.matisse.engine.impl.GlideEngine;
import com.zhihu.matisse.filter.Filter;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Handler;
import android.view.Window;
import android.widget.Adapter;


import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import okhttp3.Call;
import okhttp3.Request;
import okhttp3.Response;

public class MainActivity extends AppCompatActivity implements ArticleListFragment.OnFragmentInteractionListener , AnnouncementFragment.OnFragmentInteractionListener{
    SmartRefreshLayout smartRefreshLayout;
    RecyclerView recyclerView;
    Adapter adapter;
    List<String> chatList = new ArrayList<>();
    @Override
    public void onFragmentInteraction(Uri uri) {
        System.out.println("CCCCCCCCCCCCCCCC");

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) { //相当于main函数
        super.onCreate(savedInstanceState); //创建空白页面，初始化过程
        //隐藏界面默认标题栏
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        setContentView(R.layout.activity_main); //将R.layout.activity_main与布局文件关联起来

//        try {
//            Thread.sleep(50000);
//            System.out.println(bannerList);
////            bannerList.add("http://114.116.72.149:9080/fzucms/356351b6-2aeb-4618-9a99-961a5e174059.jpg");
////            bannerList.add("http://114.116.72.149:9080/fzucms/15394169137_840x630.jpg");
////            bannerList.add("http://114.116.72.149:9080/fzucms/820bea354a5f9f7fe11ee26b9aaa4252.jpeg");
////            bannerList.add("http://114.116.72.149:9080/fzucms/Snipaste_2023-03-30_09-13-11.png");
//
//
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }

//        RefreshLayout refreshLayout = this.findViewById(R.id.refreshLayout);
//        refreshLayout.setRefreshHeader(new ClassicsHeader(this));
//        RecyclerView recyclerView = this.findViewById(R.id.recyclerView);
//        refreshLayout.setRefreshContent(recyclerView);
//        refreshLayout.setRefreshFooter(new ClassicsFooter(this));
//        refreshLayout.setOnRefreshListener(new OnRefreshListener() {
//            @Override
//            public void onRefresh(RefreshLayout refreshlayout) {
//                refreshlayout.finishRefresh(2000/*,false*/);//传入false表示刷新失败
//            }
//        });
//        refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
//            @Override
//            public void onLoadMore(RefreshLayout refreshlayout) {
//                refreshlayout.finishLoadMore(2000/*,false*/);//传入false表示加载失败
//            }
//        });
//        Matisse.from(this) //Activity
//                .choose(MimeType.ofAll()) //选择全部（包括视频）
//                .countable(true)  // 有序选择图片
//                .maxSelectable(9)  //最大选择数量为9
//                .gridExpectedSize(400)  //图片显示表格的大小
//                .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
//                .thumbnailScale(0.85f)  //缩放比率
//                .theme(R.style.Matisse_Zhihu) //主题  暗色主题 R.style.Matisse_Dracula
//                .imageEngine(new GlideEngine()); //加载方式
//                .forResult(REQUEST_CODE_CHOOSE); //结果返回码 ，在onActivityResult中获取


        BottomNavigationView navView = findViewById(R.id.nav_view);
        navView.setBackgroundColor(Color.rgb(255,250,205));

        AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
                R.id.navigation_home, R.id.navigation_articleList, R.id.navigation_add, R.id.navigation_downloads, R.id.navigation_me)
                .build();
        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
        NavigationUI.setupWithNavController(navView, navController);

        //设置顶部状态栏黑底白字（最上面这一行显示电池、时钟、wifi等图标是状态栏）
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            getWindow().setStatusBarColor(Color.BLACK);
        }

        //设置系统底部导航栏背景色为黑色（三指导航）
        getWindow().setNavigationBarColor(Color.BLACK);

            //从一个Activity跳转到另外一个Activity的Fragment上
//        int id = getIntent().getIntExtra("id", 0);
//        if (id == 1) {
//            getSupportFragmentManager()
//                    .beginTransaction()
//                    .replace(R.id.nav_host_fragment,new MeFragment())
//                    .addToBackStack(null)
//                    .commit();
//        }





    }

}
